import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui';
import axios from "axios";
import qs from "qs";
import 'element-ui/lib/theme-chalk/index.css';

// 设置原型 this.$http.post
Vue.prototype.$axios = axios;
Vue.prototype.$http = axios;
// 设置默认的路径为后台服务器的ip和端口
Vue.prototype.$axios.defaults.baseURL = "http://localhost:9000";
// 设置qs原型
Vue.prototype.$qs = qs;
//配置axios拦截请求，添加token头信息
axios.interceptors.request.use(
    config => {
      let accesstoken = localStorage.getItem("access-token");
      // let freshtoken = localStorage.getItem("refresh-token");
      console.log("拦截请求access-token--->" + accesstoken);
      // console.log("拦截请求fresh-token--->" + freshtoken);
      if (accesstoken) {
        //把localStorage的token放在Authorization里
        config.headers.Authorization = accesstoken;
        // config.headers.RefreshToken = freshtoken;
      }
      return config;
    },
    function(err) {
      console.log("失败信息" + err);
    }
);
//配置element
Vue.use(ElementUI);
Vue.config.productionTip = false

new Vue({
  router,
  render: function (h) { return h(App) }
}).$mount('#app')
